<?php
class FileManager {
    private $fileName;

    function __construct($fileName) {
        $this->fileName = $fileName;
    }

    function getContentFile() {
        return fopen($this->fileName ,r);
    }

    function getContentFileToWrite() {
        return fopen($this->fileName ,w);
    }

    function displayContentFile($fileContent) {
        while (!feof($fileContent)) {
            $buffer = fgets($fileContent);
            echo $buffer."<br>";
        }
        fclose($fileContent);
    }

    function displayContentFileWithoutTags($fileContent) {
        while (!feof($fileContent)) {
            $buffer = fgets($fileContent);
            echo str_replace("<br />","\n",strip_tags($buffer,"<br>"));
        }
        fclose($fileContent);
    }

    function displaySomeContentFile($fileContent, $recordToDisplay) {
        $buffer = '';
        while (!feof($fileContent)) {
            $buffer = $buffer.fgets($fileContent);
        }
        $buffer = substr($buffer,0,$recordToDisplay)."</p>";
        echo $buffer;
        fclose($fileContent);
    }

    function writeFile ($fileContent, $fill) {
        fwrite($fileContent,$fill);
        fclose($fileContent);
    }
}
?>
